package com.geekaca.d09;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

public class TestStringByte3 {
    public static void main(String[] args) {
        byte[] bytes = "Hello".getBytes();

        for (int i = 0; i < bytes.length; i++) {
            System.out.println(bytes[i]);
        }

        String str = new String(bytes);
        System.out.println(str);

        byte[] btArr = "你好".getBytes(StandardCharsets.UTF_8);
        String gbkHello = new String(btArr, Charset.forName("GBK"));
        String uncodeHello = new String(btArr);
        System.out.println(gbkHello);
        System.out.println(uncodeHello);
    }
}
